package com.housing.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.housing.domain.Attachment;
import com.housing.domain.vo.AttachmentVo;
import com.zmetaport.common.core.utils.MapstructUtils;
import com.zmetaport.common.mybatis.core.mapper.BaseMapperX;

import java.util.List;

/**
 * 【请填写功能名称】Mapper接口
 *
 * @author chensm
 * @date 2024-12-15
 */
public interface AttachmentMapper extends BaseMapperX<Attachment, AttachmentVo> {

    default List<AttachmentVo> queryBySource(Long sourceId, Integer type) {
        List<Attachment> attachments = this.selectList(new LambdaQueryWrapper<Attachment>()
                .eq(Attachment::getSourceId, sourceId).eq(Attachment::getSourceType, type));
        return MapstructUtils.convert(attachments, AttachmentVo.class);

    }
}
